local game = require "club.threecard.roulette"
local Vector3 = CS.UnityEngine.Vector3

local log = game.logging.get("o")

local no2angle = 
{
    [0] = -15;
    [26] = -5;
    [3] = 4;
    [35] = 14;
    [12] = 23.7;
    [28] = 33.7;
    [7] = 42.9;
    [29] = 53.1;
    [18] = 62.8;
    [22] = 72.4;
    [9] = 81.8;
    [31] = 91.6;
    [14] = 101;
    [20] = 110.3;
    [1] = 120.8;
    [33] = 129.8;
    [16] = 140.1;
    [24] = 149.8;
    [5] = 159.3;
    [10] = 168.4;
    [23] = 178.7;
    [8] = 187.9;
    [30] = 198.2;
    [11] = 208.2;
    [36] = 218.1;
    [13] = 228;
    [27] = 237.6;
    [6] = 247.1;
    [34] = 257.7;
    [17] = 267.1;
    [25] = 276.1;
    [2] = 286.3;
    [21] = 296.4;
    [4] = 306.2;
    [19] = 315.7;
    [15] = 325.2;
    [32] = 335.3;
}

local o = game.ui.element()

function o:on_set_gameobject()
    self:super("on_set_gameobject")
    self.loaded = true
end

function o:set_no(no)
    local angle = no2angle[no];
    if not angle then
        log.error("错误的no="..no)
        return;
    end
    self.o.localEulerAngles = Vector3(0, 0, angle);
end

function o:play(no)
    self:set_no(no);
    self:show();
    self.animator:Play("o_clip_1");
end

return o;